import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;

@RunWith(JMock.class)
public class ExampleJMockClass{
	@Before
	public void doBefore(){
		/*same to the example of JUnit*/
	}
	@After
	public void doAfter(){
		/*same to the example of JUnit*/
	}
	@Test
	public void doTest(){
		//create the factory for all mock objects
		Mockery mockery = new JUnit4Mockery();
		//create a mock object for a concrete class
		ToTestClass c = mockery.mock(ToTestClass.class);
		//input for the method to be simulated
		final int input = 1;
		//result for the method to be simulated
		final String result = "result for test";
		//set the expectations (simulations) of JMock
		mockery.checking(new Expectations(){{
			allowing (c).doSomething(input); 
			will(returnValue(result));
			/*other allowing here*/
		}};
		//the value shoud equal result, 
		//in other words "result for test"
		String value = c.doSomething(input);
	}
}